package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.BuyDetailBean;
import com.project.bean.BuyOrderBean;
import com.project.service.IBuyOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("buyOrder")
@Api(tags = "采购订单控制器")
public class BuyOrderController {
    @Autowired
    private IBuyOrderService service;

    @RequiresPermissions("buy:find")
    @RequestMapping("cutByItem")
    @ApiOperation(value = "采购订单分页", notes = "采购订单分页")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNO", value = "页码",required = true),
            @ApiImplicitParam(name = "sName", value = "供应商名称"),
            @ApiImplicitParam(name = "startDate", value = "采购起始日期"),
            @ApiImplicitParam(name = "endDate", value = "采购结束日期")
    })
    public IPage<BuyOrderBean> cutByItem(Integer pageNO, String sName, LocalDate startDate, LocalDate endDate) {
        return service.cutByItem(pageNO, sName, startDate, endDate);
    }

    @RequiresPermissions("buy:find")
    @RequestMapping("findDetailByOrderId")
    @ApiOperation(value = "根据采购订单id查看采购明细", notes = "根据采购订单id查看采购明细")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "buyOrderId", value = "采购订单id")
    })
    public BuyOrderBean findDetailByOrderId(Integer buyOrderId) {
        return service.findDetailByOrderId(buyOrderId);
    }


}
